<?php

namespace App\Http\Controllers;

use App\Models\Admin;
use App\Models\Pay;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class BalanceController extends AdminController
{
   public function  index(Request $request){
       $where=array();
       if(!empty($request->name)){
           $where[]=array("admin.name",'like',"%".$request->name."%");
       }
       if(!empty($request->email)){
           $where[]=array("admin.email",'like',"%".$request->email."%");
       }
       if(!empty($request->number)){
           $where[]=array("pay.number",'like',"%".$request->number."%");
       }

      $list =  Pay::join("admin","admin.id","=","pay.aid")->where($where)->orderby("pay.id","desc")->select("admin.*","pay.*",'pay.created_at as time')->paginate(20);
//       dd($list);

       $append = array();
       $re = $request->toArray();
       foreach ($re as $key => $value) {
           $append[$key] = $value;
       }
       $list->appends($append);

       return view("balance.list",['data'=>$list]);

   }


   public function needpay(){

       dd();



   }




}
